//
//  EmoticonCollectionViewCell.swift
//  表情键盘
//
//  Created by 陈恒均 on 2018/2/23.
//  Copyright © 2018年 陈恒均. All rights reserved.
//

import UIKit

class EmoticonCollectionViewCell: UICollectionViewCell {
    
    //懒加载属性
    
    private lazy var emoticonBtn : UIButton = UIButton()
    
    var emotion : Emoticon?{
        didSet{
            guard let emoticon = emotion else{
                return
            }
           
            emoticonBtn.setImage(UIImage(contentsOfFile: emoticon.pngPath ??
                ""), for: .normal)
            emoticonBtn.setTitle(emoticon.emojiCode, for: .normal)
            
            if emoticon.isRemove {
                
                emoticonBtn.setImage(UIImage(named: "compose_emotion_delete"), for: .normal)
                
            }
        }
    }
    
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
// MARK:- 设置UI
extension EmoticonCollectionViewCell{
    private func setupUI(){
        contentView.addSubview(emoticonBtn)
        emoticonBtn.frame = contentView.bounds
        emoticonBtn.isUserInteractionEnabled = false
        emoticonBtn.titleLabel?.font = UIFont.systemFont(ofSize: 32)
    }
}
